package com.itchu.customer;

import com.itchu.system.domain.Song;
import com.itchu.system.service.SongService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/song")
public class vSongController {

    @Autowired
    private SongService songService;

    /**
     * 根据排行榜查询歌曲
     * @param type   1,是飙升榜    2，人气榜      3，收藏榜
     * @return
     */
    @GetMapping("/of/rank")
    public ResponseEntity<List<Song>> findRankSongs(
            @RequestParam(value = "type") Long type
    ) {
        List<Song> list = songService.findRankSongs(type);
        return ResponseEntity.ok(list);
    }

    /**
     * 按名字做模糊搜索
     * @param name
     * @return
     */
    @GetMapping("search/Songs")
    public ResponseEntity<List<Song>> searchSongsByName(
            @RequestParam(value = "name") String name
    ) {
        List<Song> list = songService.findSonsBySnameAndSiname(name);
        return ResponseEntity.ok(list);
    }

}
